package predatorprey;
import java.util.*;
/**
 *
 * @author Kenneth Aamås, Vegard Hovlid, Eirik Korsnes.
 */
public abstract class Animal extends Agent
{
    // Whether the animal is a female or not.
    //protected boolean female;
    // The animal's age.
    protected int age;
    // The animal's hunger level.
    protected int hunger;
    
    
    private static Random rnd = new Random();
    
    public Animal(Field field, Location location)
    {
        super(field, location);
        alive = true;
        //female = rnd.nextBoolean();
        age = 0;
        
    }
    
    /**
     * Indicate that the animal is no longer alive.
     * It is removed from the field.
     */
    protected void setDead()
    {
        alive = false;
        if(location != null) 
        {
            field.clear(location);
            location = null;
            field = null;
        }
    }
    
    /**
     * Make the animal more hungry. This could result in the animal's death.
     */
    protected void incrementHunger()
    {
        hunger--;
        if(hunger <= 0)
        {
            setDead();
        }
    }
}
